package org.thanos.demo.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;

import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

@Configuration
public class ScheduleConfig implements SchedulingConfigurer {

    @Bean(name = "executorOne")
    public Executor executorOne() {
        return Executors.newSingleThreadExecutor();
    }

    @Bean(name = "executorTwo")
    public Executor executorTwo() {
        return Executors.newSingleThreadExecutor();
    }

    @Override
    public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) {
//        System.out.println(scheduledTaskRegistrar.getCronTaskList());
//        System.out.println(scheduledTaskRegistrar.getFixedDelayTaskList());
//        System.out.println(scheduledTaskRegistrar.getFixedRateTaskList());
//        System.out.println(scheduledTaskRegistrar.getScheduledTasks());
//        scheduledTaskRegistrar.setFixedDelayTasksList(Collections.emptyList());
//        scheduledTaskRegistrar.setFixedRateTasksList(Collections.emptyList());
    }
}
